package main

import (
	"fmt"
	"math/rand"
	"time"
)

func main() {
	//guessNumbers(1, 100)
	printPrimeNumber()
}

func guessNumbers(min, max int) {
	var maxTimes = 10
	r := rand.New(rand.NewSource(time.Now().UnixNano()))
	var random = r.Intn(max-min) + min
	var result int
	for i := 1; i <= maxTimes; i++ {
		fmt.Println("请输入1-100以内的数字：")
		fmt.Scanln(&result)
		if result != random {
			switch i {
			case maxTimes:
				fmt.Println("说你点啥好呢！")
			default:
				if result > random {
					fmt.Println("太大了，再试一次吧！")
				} else {
					fmt.Println("太小了，再试一次吧！")
				}
			}
			continue
		} else {
			switch {
			case i == 1:
				fmt.Println("你真是个天才！")
			case i >= 2 && i <= 3:
				fmt.Println("你很聪明，快赶上我了！")
			case i >= 4 && i <= 9:
				fmt.Println("一般般啊！")
			default:
				fmt.Println("可算猜对了！")
			}
			break
		}
	}
}

func printPrimeNumber() {
	primeNumber := 0
	sum := 0
	for i := 2; i < 100; i++ {
		isPrime := true
		for j := 2; j <= i/2; j++ {
			if i%j == 0 {
				isPrime = false
				break
			}
		}
		if isPrime {
			sum += i
			primeNumber++
			fmt.Printf("\t%d", i)
			if primeNumber%5 == 0 {
				fmt.Printf("\n")
			}
		}
	}
	fmt.Println("\n\tsum =", sum)
}
